package luo_xiang_yuan;

public class LUO_XIANG_YUAN_Q2 {
    private  int maxSize = 10;
    private int[] Queue = new int[maxSize];
    private int length;//记录数组的长度
    //队满
    public boolean isFull(){
        return length == maxSize;
    }
   //队空
    public boolean isEmpty(){
        return length == 0;
    }
   //输入
    public void push(int value){
        if(isFull ()){
            System.out.println ("已满");
        }
        Queue[length] = value;
        length++;
    }

    public int pop(){
        if(isEmpty ()){
            System.out.println ("空栈");
        }
        int index = 0;
        int value = Queue[index];
        //输出头，后面的前移
        for(int j=1;j<Queue.length;j++){
            Queue[j-1] = Queue[j];
            index++;
        }
        length--;
        return value;
    }

    public int size(){
        return this.length;
    }

    public static void main(String[] args) {
        LUO_XIANG_YUAN_Q2 aq = new LUO_XIANG_YUAN_Q2 ();
        aq.push ( 1 );
        aq.push ( 2 );
        aq.push ( 3 );
        aq.push ( 4 );
        aq.push ( 5 );
        System.out.println (aq.pop ());
        System.out.println (aq.pop ());
        System.out.println (aq.pop ());
        System.out.println ("长度"+aq.size ());
    }

}
